<!DOCTYPE HTML>
<html lang="zh-CN">






<head>
    <!--让百度解析-->
    <meta name="baidu-site-verification" content="code-BwRMg6yW1H" />

    <meta charset="utf-8">


    <meta name="keywords" content="HashMap相关小知识点, keys">
    <meta name="description" content="站长很懒，什么都没有留下....">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>HashMap相关小知识点 | 张小菜</title>
    <link rel="icon" type="image/gif" style="width: 100%;height: 100%;" href="/../../images/logoOne.gif">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

    <!--雪花飘落代码块-->
    

    <!--樱花飘落代码块-->
    

    <!--点击显示文字效果-->
    
        <script type="text/javascript">
          //只在桌面版网页启用特效
          var windowWidth = $(window).width();
          if (windowWidth > 768) {
            document.write('<script type="text/javascript" src="/js/wenzi.js"><\/script>');
        }
    </script>
    


<meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="张小菜" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>



   <style>
    body{
       background-image: url('/medias/background.jpg');
       background-repeat:no-repeat;
       background-size:cover;
       background-attachment:fixed;
    }
</style>




<body>
    <header class="navbar-fixed">
    <script>
        /*这段代码用于百度统计植入代码*/
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?851ba41937b8a3d4d644c8216f055c91";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>

    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/../../images/logoOne.gif" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">张小菜</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
    
        <li class="hide-on-med-and-down nav-item">
            
                <a href="/" class="waves-effect waves-light">
                    
                        <i class="fas fa-home" style="zoom: 0.6;"></i>
                    
                    <span>首页</span>
                </a>
            
        </li>
    
        <li class="hide-on-med-and-down nav-item">
            
                <a href="/tags" class="waves-effect waves-light">
                    
                        <i class="fas fa-tags" style="zoom: 0.6;"></i>
                    
                    <span>标签</span>
                </a>
            
        </li>
    
        <li class="hide-on-med-and-down nav-item">
            
                <a href="/categories" class="waves-effect waves-light">
                    
                        <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
                    
                    <span>分类</span>
                </a>
            
        </li>
    
        <li class="hide-on-med-and-down nav-item">
            
                <a href="/archives" class="waves-effect waves-light">
                    
                        <i class="fas fa-archive" style="zoom: 0.6;"></i>
                    
                    <span>归档</span>
                </a>
            
        </li>
    
        <li class="hide-on-med-and-down nav-item">
            
                <a href="/about" class="waves-effect waves-light">
                    
                        <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
                    
                    <span>关于</span>
                </a>
            
        </li>
    
        <li class="hide-on-med-and-down nav-item">
            
                <a target="_blank" rel="noopener" href="https://www.zdzn.net/" class="waves-effect waves-light">
                    
                        <i class="fas fa-comments" style="zoom: 0.6;"></i>
                    
                    <span>聚宝盒</span>
                </a>
            
        </li>
    
        <li class="hide-on-med-and-down nav-item">
            
                <a href="" class="waves-effect waves-light">

                    
                        <i class="fa fa-heartbeat" style="zoom: 0.6;"></i>
                    
                    <span>功能</span>
                    <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
                </a>
                <ul class="sub-nav menus_item_child ">
                    
                        <li>
                            <a target="_blank" rel="noopener" href="http://43.138.208.196:8080/examsSystem/index.jsp">
                                
                                    <i class="fab fa-codepen" style="margin-top: -20px; zoom: 0.6;"></i>
                                
                                <span>考试系统</span>
                            </a>
                        </li>
                    
                        <li>
                            <a target="_blank" rel="noopener" href="http://43.138.208.196/page/login.html">
                                
                                    <i class="fab fa-dev" style="margin-top: -20px; zoom: 0.6;"></i>
                                
                                <span>shell-web</span>
                            </a>
                        </li>
                    
                        <li>
                            <a target="_blank" rel="noopener" href="http://43.138.208.196:8081/html/Login.html">
                                
                                    <i class="fab fa-artstation" style="margin-top: -20px; zoom: 0.6;"></i>
                                
                                <span>基金系统</span>
                            </a>
                        </li>
                    
                        <li>
                            <a href="http://zhangxiaocainb.gitee.io/music-player">
                                
                                    <i class="fa fa-music" style="margin-top: -20px; zoom: 0.6;"></i>
                                
                                <span>我的音乐</span>
                            </a>
                        </li>
                    
                </ul>
            
        </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
        </a>
    </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/../../images/logoOne.gif" class="logo-img circle responsive-img">
        
        <div class="logo-name">张小菜</div>
        <div class="logo-desc">
            
            站长很懒，什么都没有留下....
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a target="_blank" rel="noopener" href="https://www.zdzn.net/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fa fa-heartbeat"></i>
			
			Functions
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>

                  <a target="_blank" rel="noopener" href="http://43.138.208.196:8080/examsSystem/index.jsp " style="margin-left:75px">
				  
				   <i class="fa fab fa-codepen" style="position: absolute;left:50px" ></i>
			      
		          <span>考试系统</span>
                  </a>
                </li>
              
                <li>

                  <a target="_blank" rel="noopener" href="http://43.138.208.196/page/login.html " style="margin-left:75px">
				  
				   <i class="fa fab fa-dev" style="position: absolute;left:50px" ></i>
			      
		          <span>shell-web</span>
                  </a>
                </li>
              
                <li>

                  <a target="_blank" rel="noopener" href="http://43.138.208.196:8081/html/Login.html " style="margin-left:75px">
				  
				   <i class="fa fab fa-artstation" style="position: absolute;left:50px" ></i>
			      
		          <span>基金系统</span>
                  </a>
                </li>
              
                <li>

                  <a href="http://zhangxiaocainb.gitee.io/music-player " style="margin-left:75px">
				  
				   <i class="fa fa fa-music" style="position: absolute;left:50px" ></i>
			      
		          <span>我的音乐</span>
                  </a>
                </li>
              
            </ul>
          
        </li>
        
        
    </ul>
</div>


        </div>

        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('该文章需要密码才能访问哦！')).toString(CryptoJS.enc.Hex)) {
                alert('密码错误，将返回主页！');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/14.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">HashMap相关小知识点</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/HashMap/">
                                <span class="chip bg-color">HashMap</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/java/" class="post-category">
                                java
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-08-29
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2021-09-01
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    4.9k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>预计阅读时长:&nbsp;&nbsp;
                    18 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h3>一、类的泛型</h3>

<p>泛型的定义语法如下：</p>
<p><span style='color:red'>[访问修改符] class 类名称<T></span></p>
<p>泛型解释:</p>
<p>就是当该类在实例化的时候（如：Person<String> person=new Person<String>(xxx);）在类名后方加上类型，此时class 类名称<T>的值就为String，那么这么应用有什么用呢？</p>
<p>先上代码:</p>
<pre class=" language-java"><code class="language-java"><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">Base</span><span class="token operator">&lt;</span>T<span class="token operator">></span><span class="token punctuation">{</span>
   <span class="token comment" spellcheck="true">//这里用T这个类上的泛型可以用来定义变量，当然该变量此时的类型还无法确定，只有等到该类被实例化之后(必须以    //上述方法实例化)</span>
    T m<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>该泛型<T>可以用来定义变量或者方法参数类型，但在给该泛型指定类型时需要注意的是:泛型的类型只能是包装类型，不得是基本类型。</p>
<h3>二、java关键词transient</h3>

<p>transient是短暂的意思，他是用来修饰成员变量的(也就是代替public、private等)。</p>
<p>特点:transient修饰的变量不能被序列化(transient修饰的变量不能再网上传输)，主要考虑的是隐秘数据的安全性(这是需要注意的是static修饰的变量也是不能被序列化的)，transient只能修饰成员变量，不能修饰类和方法。</p>
<h3>三、位运算</h3>

<p>介绍位运算符有哪些?</p>
<p>非(~)、与(&amp;)、或(|)、异或(^)、左位移(&lt;&lt;[&lt;&lt;&lt;])、右位移(&gt;&gt;[&gt;&gt;&gt;])</p>
<p>说明，上述位运算符运算的数字必须都是二进制数字，如果不是二进制数字，需要转换成二进制数字运算(一般java会自动转换)。</p>
<h5 id="与-amp"><a href="#与-amp" class="headerlink" title="与  &amp;"></a>与  &amp;</h5><p>按照两组二进制的数字一 一按位置对比，操作数中都都为一，结果才为一，否则都为零，如下:</p>
<p>11010 &amp; 10010 =10010</p>
<h5 id="或"><a href="#或" class="headerlink" title="或  |"></a>或  |</h5><p>按照两组二进制的数字一 一按位置对比，操作数中只要有一方为一，结果就为一，否则为零，如下:</p>
<p>11010 &amp; 10010 =11010</p>
<h5 id="非"><a href="#非" class="headerlink" title="非  ~"></a>非  ~</h5><p>只需要一组二进制数字就可以进行非运算，进制数当中，值是一则转为零，值是零则转为一，如下:</p>
<p>11010=00101</p>
<h5 id="异或"><a href="#异或" class="headerlink" title="异或  ^"></a>异或  ^</h5><p>按照两组二进制的数字一 一按位置对比，两方操作数相同则为零，两方操作数不相同则为一，如下:</p>
<p>11010 &amp; 10010 =01000</p>
<h5 id="左位移-lt-lt"><a href="#左位移-lt-lt" class="headerlink" title="左位移  &lt;&lt;"></a>左位移  &lt;&lt;</h5><p>语法: 需要位移的数字 &lt;&lt; 需要位移次数</p>
<p>对一组二进制数进行改变(如果不是二进制数则转换成二进制数运算，运算后的二进制结果再转换回来即可)，将整个二进制数向左进行位移，最左侧的数字直接砍掉，正数左移高位补0，负数左移高位还是补0，如下:</p>
<p>0000 0000 0000 0000 0000 0000 0000 1011 &lt;&lt; 2 = 0000 0000 0000 0000 0000 0000 0010 1100</p>
<h5 id="右位移-gt-gt"><a href="#右位移-gt-gt" class="headerlink" title="右位移 &gt;&gt;"></a>右位移 &gt;&gt;</h5><p>语法:需要位移的数字 &gt;&gt; 需要位移的次数</p>
<p>解释如上述左位移方式相反，正数右移高位补0，负数右移高位补1，示列如下:</p>
<p>0000 0000 0000 0000 0000 0000 0000 1011 &gt;&gt; 2 = 0000 0000 0000 0000 0000 0000 0000 0010</p>
<p>-0000 0000 0000 0000 0000 0000 0000 1011 &gt;&gt; 2 = -1100 0000 0000 0000 0000 0000 0000 0010</p>
<h5 id="无符号右移-gt-gt-gt"><a href="#无符号右移-gt-gt-gt" class="headerlink" title="无符号右移 &gt;&gt;&gt;"></a>无符号右移 &gt;&gt;&gt;</h5><p>语法: 需要位移的数字 &gt;&gt;&gt; 需要位移次数</p>
<p>和右位移是兄弟，非常相似，将整个二进制数向左进行位移，最右侧的数字直接砍掉，无论是正数还是负数，高位统统补0[唯一不同的地方]，如下:</p>
<p>0000 0000 0000 0000 0000 0000 0000 1011 &gt;&gt;&gt; 2 = 0000 0000 0000 0000 0000 0000 0000 0010</p>
<p>-0000 0000 0000 0000 0000 0000 0000 1011 &gt;&gt;&gt; 2 = 1100 0000 0000 0000 0000 0000 0000 0010</p>
<blockquote>
<p>说明:以上的所有操作可以对数字或者是字母进行操作，只不过在操作的时候要事先转换成二进制数字(许多编译器都可以自动转换)，运算完毕之后得到的也是二进制数，此时再将二进制数转换成我们想要得值就可以了。</p>
</blockquote>
<h3 id="四、方法的返回值native是什么"><a href="#四、方法的返回值native是什么" class="headerlink" title="四、方法的返回值native是什么"></a>四、方法的返回值native是什么</h3><p>1、一个native方法就是一个Java调用<strong>非Java代码</strong>的接口。一个native方法是指该方法它的实现由非Java语言实现，比如用C或C++实现，主要是因为JAVA无法对操作系统底层进行操作，但是可以通过jni(java native interface)调用其他语言来实现底层的访问。</p>
<h3 id="五、java8后有了一个新特性"><a href="#五、java8后有了一个新特性" class="headerlink" title="五、java8后有了一个新特性"></a>五、java8后有了一个新特性</h3><p>接口不再是只能写抽象方法，它还可以实现方法体，但需要实现的方法体需要用dufualt或者是static定义，其目的是为了增加接口方法时降低改动范围(因为增加一个普通抽象方法需要子类都实现)，因为实现的方法体不是必须实现的，而是像继承一样默认继承的，有趣的是：当一个接口中编写了一个static定义的实现方法，那么调用这个方法是只需要接口名点方法名的方式，非常的方便。</p>
<h3 id="六、关于复杂的泛型"><a href="#六、关于复杂的泛型" class="headerlink" title="六、关于复杂的泛型"></a>六、关于复杂的泛型</h3><h6 id="类名-lt-类型-extends-类型-gt-变量名-如-Persion-lt-？-extends-E-gt-person"><a href="#类名-lt-类型-extends-类型-gt-变量名-如-Persion-lt-？-extends-E-gt-person" class="headerlink" title="类名&lt;类型 extends 类型&gt; 变量名  如: Persion&lt;？ extends E&gt; person"></a>类名&lt;类型 extends 类型&gt; 变量名  如: Persion&lt;？ extends E&gt; person</h6><p>解释:定义该Persson是我们需要给定一个泛型(注意 : 只需要给定一个，相当于填充？[这里的问号等同于object]位置)，extends的意思相当于继承前方的”类型”，该类型可以是不确定类型(？位置)也可以是指定的类型，其实看到这里我们就能明白，我们给定的泛型必须是继承前方类型的，也就是只能是前方类型的子类(不能是它的父类或者是它类型的本身)，整体就是为了给本次泛型添加一个类型的约束。</p>
<h6 id="类名-lt-类型-super-类型-gt-变量名-如-Persion-lt-super-E-gt-person"><a href="#类名-lt-类型-super-类型-gt-变量名-如-Persion-lt-super-E-gt-person" class="headerlink" title="类名&lt;类型 super 类型&gt; 变量名  如: Persion&lt;? super E&gt; person"></a>类名&lt;类型 super 类型&gt; 变量名  如: Persion&lt;? super E&gt; person</h6><p>解释:这里的super和上述的extends完全相反，意思是该次添加的泛型必须是前方类型的子类(只能是子类，不能是后方类型本身)</p>
<h3>七、ListIterator迭代器</h3>

<p>ListIterator迭代器继承了Iterator所有方法，并且还扩充了很多操作List的方法，但如果要使用它，必须要继承List集合，那么有了foreach我们为什么还需要ListIterator迭代器呢，因为foreach在遍历集合时是不允许添加集合元素的，这让我们只能单线操作集合，但ListIterator解决了这个问题，所以在某些特殊情况下我们还是需要使用ListIterator。</p>
<h3 id="八、哈希表是数组和单项列表的集合"><a href="#八、哈希表是数组和单项列表的集合" class="headerlink" title="八、哈希表是数组和单项列表的集合"></a>八、哈希表是数组和单项列表的集合</h3><p>Set集合: HashMap</p>
<ol>
<li>Hashset底层实际上是一个HashMap , HashMap底层采用了哈希表数据结构。</li>
<li>哈希表又叫做散列表，哈希表底层是一一个数组，这个数组中每一-个元素<br>是一个单向链表。每个单向链表都有一个独一无二的hash值，代表数组的<br>下标。在某个单向链表中的每一个节点上的hash值是相等的。hash值实际上<br>是key调用hashCode方法，在通过”hash function”转 换成的值。</li>
<li>如何向哈希表中添加元素:<br>先调用被存储的key的hashCode方法，经过某个算法得出hash值，如果在<br>这个哈希表中不存在这个hash值，则直接加入元素。如果该hash值已经<br>存在，继续调用key之间的equals方法，如果equals方法返回false,则将<br>该元素添加。如果equals方法返回true,则放弃添加该元素。</li>
<li>HashSet其实是HashMap中的key部分。HashSet有什 么特点，HashMap中 的key应该具有相同的特点。</li>
</ol>
<h3 id="九、instanceof"><a href="#九、instanceof" class="headerlink" title="九、instanceof"></a>九、instanceof</h3><pre class=" language-java"><code class="language-java">Boolean result<span class="token operator">=</span> obj <span class="token keyword">instanceof</span> <span class="token class-name">Class</span>
</code></pre>
<p>其中 obj 为一个对象，Class 表示一个类或者一个接口，当 obj 为 Class 的对象，或者是其直接或间接子类，或者是其接口的实现类，结果result 都返回 true，否则返回false。</p>
<h3 id="十、TreeSet、SortedSet"><a href="#十、TreeSet、SortedSet" class="headerlink" title="十、TreeSet、SortedSet"></a>十、TreeSet、SortedSet</h3><p>sortedset集合存储元素为什么可以自动排序?<br>因为被存储的元素实现了Comparable接口，<br>SUN编写TreeSet集否在添加元素的时候，会<br>调用compareTo方法完成比较</p>
<h3 id="十一、HashTable、Properties"><a href="#十一、HashTable、Properties" class="headerlink" title="十一、HashTable、Properties"></a>十一、HashTable、Properties</h3><p>HashTable继承与Map，效率低，但是线程安全，它有一个子类是Properties，是一个非常重要的属性类，它的特点是只能存储字符串类型的键值对。</p>
<h3 id="十二、Iterable、Iterator、Collection"><a href="#十二、Iterable、Iterator、Collection" class="headerlink" title="十二、Iterable、Iterator、Collection"></a>十二、Iterable、Iterator、Collection</h3><p>1、Iterator是一个迭代接口，它当中的方法有:hasNext()判断是否还有下一个元素、next()取出指针的下一个元素(刚开始时指针位于第一个元素的上方)、remove()删除指针所指的元素。</p>
<p>2、Iterable是一个象征性的迭代接口，它的内部只有一个返回类型为Iterator迭代器的方法，它被Collection所继承，所以Collection及其子类都可以使用迭代方法，一般用法是在集合内部实现iterator迭代方法，在迭代方法内部创建并返回一个内部类(这个内部类继承Iterator，所有拥有所有的遍历方法)的实例，其次foreach方法的底层实际也是iterator迭代器实现，迭代器有个缺点，在遍历时不可以进行增删操作，这时List集合有个子类ListIterator类解决了该问题。</p>
<p>3、Collection有两个子类，分别是List，Set</p>
<h3 id="十三、ArrayList、LinkedList、Vector"><a href="#十三、ArrayList、LinkedList、Vector" class="headerlink" title="十三、ArrayList、LinkedList、Vector"></a>十三、ArrayList、LinkedList、Vector</h3><p>ArrayList是比较常用的类，其底层是通过数组实现，那么查询效率高，但是不方便增删操作(增删效率低，因为增删是需要移动数组元素的位置)。</p>
<p>LikedList底层是通过双向链表实现，查询效率低，但是增删方便。</p>
<p>Vector不经常使用，和ArrayList非常相似，ArrayList是线程不安全的，Vector是线程安全的，但是效率相对低一些。</p>
<h3 id="十四、this"><a href="#十四、this" class="headerlink" title="十四、this()"></a>十四、this()</h3><p>意为调用空构造器</p>
<h3 id="十五、关于LikedList双向链表的保存方法方式的解析"><a href="#十五、关于LikedList双向链表的保存方法方式的解析" class="headerlink" title="十五、关于LikedList双向链表的保存方法方式的解析"></a>十五、关于LikedList双向链表的保存方法方式的解析</h3><p>个人解析后编写的证明案例：</p>
<pre class=" language-java"><code class="language-java">    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">MyMains</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        List<span class="token operator">&lt;</span>m<span class="token operator">></span> list<span class="token operator">=</span><span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token operator">&lt;</span><span class="token operator">></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        m m <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">m</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>m<span class="token punctuation">)</span><span class="token punctuation">;</span>
        m<span class="token punctuation">.</span>age<span class="token operator">=</span><span class="token number">10</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>list<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">static</span> <span class="token keyword">class</span> <span class="token class-name">m</span><span class="token punctuation">{</span>
        <span class="token keyword">int</span> age<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token comment" spellcheck="true">//调用MyMains方法后输出10</span>
</code></pre>
<p>解释:当我们在形参中传入引用类型，如果后面我修改了引用类型中的属性，形参中传入的引用类型的属性值也会跟着改变。</p>
<h3 id="十六、关于阅读LInkedList源码须知-部分"><a href="#十六、关于阅读LInkedList源码须知-部分" class="headerlink" title="十六、关于阅读LInkedList源码须知(部分)"></a>十六、关于阅读LInkedList源码须知(部分)</h3><p>类中:first属性代表头结点：(null,元素值,后元素指向)</p>
<p>类中:last属性代表尾结点:（前元素指向,元素值,null)</p>
<p>说明:不论是增、删(这里只说明在最前面添加或者是在最后面添加元素)，其实就是在头结点前或者尾结点后添加结点，并为头结点的前元素指向新结点素的后元素，新结点的后元素指向头结点的前元素，为后结点的后元素指向新结点的前元素，新结点的前元素指向尾结点的后元素，这样就为双向链表前后各添加了一个元素，值得注意的是:结点与结点的指向必须是双向的。</p>
<h3 id="十七、static修饰外部类"><a href="#十七、static修饰外部类" class="headerlink" title="十七、static修饰外部类"></a>十七、static修饰外部类</h3><p>static除了修饰属性与方法之外，还可以修饰内部类(正常的外部类不能用static进行修饰)，static修饰内部类的好处是，创建内部类时不需要先创建外部类的实例，如果内部类没有通过static进行修饰，如果需要创建对象的话，如下所列：</p>
<pre class=" language-java"><code class="language-java">B b <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">B</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment" spellcheck="true">//第一，先创建外部类    </span>
InnerB innerB <span class="token operator">=</span> b<span class="token punctuation">.</span><span class="token keyword">new</span> <span class="token class-name">InnerB</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//在外部类实例上，创建内部类实例</span>

<span class="token comment" spellcheck="true">//在用static修饰内部类之后的示列如下:</span>
B<span class="token punctuation">.</span>InnerB innerB<span class="token operator">=</span><span class="token keyword">new</span> <span class="token class-name">B<span class="token punctuation">.</span>InnerB</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h3 id="十八、引用类型赋值"><a href="#十八、引用类型赋值" class="headerlink" title="十八、引用类型赋值"></a>十八、引用类型赋值</h3><p>当一个引用类型(对象)赋值给变量的时候，这时赋予的其实是指向该引用对象的内存地址值，使用变量时其实是通过内存地址指向该对象，通过这个结论可以得知，当对象赋值给变量时，这时改变对象中的属性值，那么变量中该对象的属性值也会改变(其实就是同一个对象)，当时String这种引用类型排外，如下列:</p>
<pre class=" language-java"><code class="language-java">    <span class="token keyword">static</span> <span class="token keyword">class</span> <span class="token class-name">M</span><span class="token punctuation">{</span>
        <span class="token keyword">int</span> age<span class="token punctuation">;</span>
        String str<span class="token punctuation">;</span>
        S s<span class="token punctuation">;</span>
        <span class="token keyword">static</span> <span class="token keyword">class</span> <span class="token class-name">S</span><span class="token punctuation">{</span>
            <span class="token keyword">int</span> id<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">MyMains1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment" spellcheck="true">//---成功案例---输出结果是1</span>
        M m <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        M<span class="token punctuation">.</span>S s<span class="token operator">=</span><span class="token keyword">new</span> <span class="token class-name">M<span class="token punctuation">.</span>S</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        m<span class="token punctuation">.</span>s<span class="token operator">=</span>s<span class="token punctuation">;</span>
        s<span class="token punctuation">.</span>id<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m<span class="token punctuation">.</span>s<span class="token punctuation">.</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment" spellcheck="true">//----输出结果是0</span>
        M m1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> val<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
        val<span class="token operator">=</span>m1<span class="token punctuation">.</span>age<span class="token punctuation">;</span>
        m1<span class="token punctuation">.</span>age<span class="token operator">=</span><span class="token number">10</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment" spellcheck="true">//----输出结果是null</span>
        M m2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        String str<span class="token operator">=</span>null<span class="token punctuation">;</span>
        str<span class="token operator">=</span>m2<span class="token punctuation">.</span>str<span class="token punctuation">;</span>
        m2<span class="token punctuation">.</span>str<span class="token operator">=</span><span class="token string">"zhenxiang"</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    System<span class="token punctuation">.</span>out<span class="token punctuation">.</span>println（<span class="token string">"----------------------------------------------------------------"</span>）

    <span class="token comment" spellcheck="true">//这个非常非常重要</span>
    <span class="token comment" spellcheck="true">//首先需要注意的是：变量保存的是内存地址，m3这个变量保存的是指向new M()内存的地址，</span>
    <span class="token comment" spellcheck="true">//m4=m3相当于m3将内存地址赋给m4，然后m3=null相当于m3这个变量不再保存new M()的内存地址，</span>
    <span class="token comment" spellcheck="true">//而m4是保存new M()的地址，所以m4输出是有对象的(实际上输出的是变量保存的内存地址)</span>
        M m3<span class="token operator">=</span><span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        M m4<span class="token operator">=</span>m3<span class="token punctuation">;</span>
        m3<span class="token operator">=</span>null<span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m4<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//输出有对象</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m3<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//输出为null</span>

    
    <span class="token comment" spellcheck="true">//一个内存地址可以由多个变量保存，就相当于有多个变量都指向该内存地址，其中任意一个变量调用该并修改该内存当中的值，</span>
    <span class="token comment" spellcheck="true">//那么其他变量再来调用时肯定会发生改变，因为他们指向的都是同一块内存</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">MyMains2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        M m <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        M m1<span class="token operator">=</span>m<span class="token punctuation">;</span>
        m1<span class="token punctuation">.</span>age<span class="token operator">=</span><span class="token number">10</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m<span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//输出值为10</span>
    <span class="token punctuation">}</span>

    <span class="token comment" spellcheck="true">//好好看一下这个案例，当m、m1两个变量都指向同一个内存的时候，m1对内存中的"任何元素(任何变量)"进行修改，那么m再来调用内存中任何元素的时候，</span>
    <span class="token comment" spellcheck="true">//调用的都是修改后的元素。</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">MyMains3</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        M m <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        M<span class="token punctuation">.</span>S s<span class="token operator">=</span><span class="token keyword">new</span> <span class="token class-name">M<span class="token punctuation">.</span>S</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        m<span class="token punctuation">.</span>s<span class="token operator">=</span>s<span class="token punctuation">;</span>
        m<span class="token punctuation">.</span>age<span class="token operator">=</span><span class="token number">100</span><span class="token punctuation">;</span>
        M m1<span class="token operator">=</span>m<span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m1<span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//100</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m1<span class="token punctuation">.</span>s<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//com.yidu.t286.test1$M$S@4554617c</span>
        m1<span class="token punctuation">.</span>s<span class="token operator">=</span>null<span class="token punctuation">;</span>
        m1<span class="token punctuation">.</span>age<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m<span class="token punctuation">.</span>age<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//0</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m<span class="token punctuation">.</span>s<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//null</span>
        
    <span class="token comment" spellcheck="true">//这个自己体会 </span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">MyMains4</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        M m <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        M m2<span class="token operator">=</span><span class="token keyword">new</span> <span class="token class-name">M</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        M m1<span class="token operator">=</span>m<span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m<span class="token punctuation">)</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        m<span class="token operator">=</span>m2<span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m<span class="token punctuation">)</span><span class="token punctuation">;</span>
        System<span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>m1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment" spellcheck="true">/*
        输出值依次为：
        com.yidu.t286.test1$M@4554617c
        com.yidu.t286.test1$M@4554617c
        com.yidu.t286.test1$M@74a14482
        com.yidu.t286.test1$M@4554617c
         */</span>
        
    <span class="token punctuation">}</span>
        
        <span class="token keyword">public</span> <span class="token keyword">void</span> 摘录部分代码<span class="token punctuation">{</span>
            RBTNode<span class="token operator">&lt;</span>t<span class="token operator">></span> y <span class="token operator">=</span> x<span class="token punctuation">.</span>right<span class="token punctuation">;</span>
            x<span class="token punctuation">.</span>right <span class="token operator">=</span> y<span class="token punctuation">.</span>left<span class="token punctuation">;</span>
            <span class="token comment" spellcheck="true">//试问，y的值会因为x.right重新赋值而发生改变吗？答:肯定不会，因为y在赋值的时候相当于指向了x.right</span>
            <span class="token comment" spellcheck="true">//的内存地址，而此时x.right重新赋值就相当于不再指向于原来的内存地址，而是重新指向y.left的内存地址，</span>
            <span class="token comment" spellcheck="true">//并不影响y指向x.right,那么在什么情况下会影响到y呢? 答: 假如 RBTNode&lt;t> y = x.right; 变换成  ：</span>
            <span class="token comment" spellcheck="true">//RBTNode&lt;t> y = x; 那么此时x.right重新指向的话，y当中的y.right也会发生改变。</span>
        <span class="token punctuation">}</span>
        
    <span class="token punctuation">}</span>
</code></pre>
<h3 id="十九、二叉树"><a href="#十九、二叉树" class="headerlink" title="十九、二叉树"></a>十九、二叉树</h3><p>二叉树删除节点选用继承者问题:</p>
<p>1、如果删除节点的子节点是叶子节点，者直接选用叶子节点即可</p>
<p>2、删除节点的只有一个子节点，则直接选用该子节点</p>
<p>3、删除节点有两个子节点，并且这两个子节点都为树节点，此时需要选用继承者时应该考虑继承者的值跟删除节点的值是否更加接近，根据二叉树的添加原则，比根节点大的放在右边，比根节点小的放在左边，那么需要取删除节点的近似值应该遵照:“左子树的最大值或者右子树的最小值”。</p>
<h3 id="二十、红黑树的特性"><a href="#二十、红黑树的特性" class="headerlink" title="二十、红黑树的特性"></a>二十、红黑树的特性</h3><p>1、每个节点都是红色或者是黑色</p>
<p>2、根节点必须为黑色</p>
<p>3、叶子节点必须为黑色</p>
<p>4、如果一个节点为红色，那么该节点的子节点必须为黑色</p>
<p>5、从根节点到子孙节点的所有路径的黑节点必须相同</p>
<h5 id="（1）红黑树插入元素时矫正"><a href="#（1）红黑树插入元素时矫正" class="headerlink" title="（1）红黑树插入元素时矫正:"></a>（1）红黑树插入元素时矫正:</h5><p>一般的插入会违背红黑树特性(1)、(4)，违背特性(1)则直接更改颜色即可，如果违背特性(4),则又分为如下四种解决思路:</p>
<p>1、插入结点的父节点为红色，叔叔结点也为红色。</p>
<p>解决方案:将父节点和叔叔结点都设置为黑色，将祖父结点设置为红色，并将祖父结点当做新的插入结点(因为当前祖父结点与它的父节点肯定会违背特性)，这并不足以矫正，只是缩小矫正范围，还需要通过下述方式进行再一步矫正。</p>
<p>2、插入结点的父节点是红色，叔叔结点为黑色。</p>
<p>分为两种情况:</p>
<p>​    父节点是祖父节点的左子节点。</p>
<p>​    又分为两种情况:</p>
<p>​        插入的节点是父节点的左子节点。</p>
<p>​        解决方案:将父节点进行右旋，将右旋后的父节点改为黑色，将右旋后的祖父结点改为红色，如此便矫正完成。</p>
<p>​        插入的节点是父节点的右子节点。</p>
<p>​        解决方案:将父节点进行左旋即可，该步并不足以完全矫正，只是形成了上述情况，再通过上述方案解决即可。</p>
<p>​    父节点是祖父节点的右子节点。</p>
<p>​    又分为两种情况:</p>
<p>​        插入的节点是父节点的左子节点。</p>
<p>​        解决方案:将父节点进行右旋，该步并不足以完全矫正，只是形成了下述情况，再通过下述方案解决即可，</p>
<p>​        插入的节点是父节点的右子节点。</p>
<p>​        解决方案:将父节点进行左旋，将左旋后的父节点改为黑色，将左旋后的祖父结点改为红色，如此便矫正完成。</p>
<p>3、插入节点的父节点是红色，叔叔节点为空的情况。</p>
<p>解决方案：通过判断父节点是祖父节点的左子节点或者是右子节点，选择左旋或者右旋，旋转后只需要将父节点设置为黑色，将祖父节点设置为红色即可。</p>
<h3 id="二十一、HashMap、HashTable、ConcurrentHashMap的区别。"><a href="#二十一、HashMap、HashTable、ConcurrentHashMap的区别。" class="headerlink" title="二十一、HashMap、HashTable、ConcurrentHashMap的区别。"></a>二十一、HashMap、HashTable、ConcurrentHashMap的区别。</h3><p>HashMap和HashTable的区别主要体现在线程安全、对键值的要求，迭代器的选择以及速度上。</p>
<p>1.线程的安全。</p>
<p>HashMap是线程非安全的，而HashTable在方法上加了同步锁，所以HashTable是线程安全的，但相应的丢失了效率。</p>
<p>2.对键值的要求。</p>
<p>HashMap允许key、value为null,而HashTable不允许key、value为null。</p>
<p>3.迭代器的选择。</p>
<p>HashMap选择的是fail-fast(快速失败)机制(实际上就相当于在迭代的时候不能对集合结构进行修改，如果结构发生改变则抛出异常)，HashTable采用fast-safe(快速安全)机制(也就是当迭代器在遍历集合的时候如果发生修改集合结构的情况，也不会发生异常)。</p>
<p>4.速度的要求</p>
<p>HashMap是线程非安全的，所以速度要高于HashTable(HashTable是线程安全的)。</p>
<p>5.ConcurrentHashMap较前两个集合有什么区别。</p>
<p>ConcurrentHashMap与之前两个集合工作原理非常相似，它也是线程安全的，但是它实现线程安全的方式与HashTable不同，HashTable是整个方法加锁，而ConcurrentHashMap是在方法内部加锁(只取关键位置加锁)，固然效率要高于HashTable，所以现在的HasHTable已经非常少用，基本上都使用ConcurrentHashMap了。</p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">张小菜</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://zhangxiaocainb.gitee.io/2021/08/29/java/hashmap/">https://zhangxiaocainb.gitee.io/2021/08/29/java/hashmap/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">张小菜</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/HashMap/">
                                    <span class="chip bg-color">HashMap</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.jpg" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments textarea {
        box-sizing: border-box;
        background: url("/medias/hmbbverymin.png") 100% 100% no-repeat;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #4cbf30;
        font-weight: 500;
        text-decoration: none;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="vcomments" class="card-content" style="display: grid">
    </div>
</div>

<script src="/libs/valine/av-min.js"></script>
<script src="/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: 'iHpJ1K3Qtp3WD6zj6lvHdXc6-MdYXbMMI',
        appKey: 'cbmLFjH9FaWQUdIVOSILOr1s',
        notify: 'true' === 'true',
        verify: 'true' === 'true',
        visitor: 'true' === 'true',
        avatar: 'monsterid',
        pageSize: '10',
        lang: 'zh-cn',
        placeholder: '来，快夸我，快'
    });
</script>

<!--酷Q推送-->


    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2021/08/31/formword/mybatis/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/12.jpg" class="responsive-img" alt="Mybatis小知识点">
                        
                        <span class="card-title">Mybatis小知识点</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-08-31
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E5%90%8E%E7%AB%AF/" class="post-category">
                                    后端
                                </a>
                            
                            <a href="/categories/java/" class="post-category">
                                    java
                                </a>
                            
                            <a href="/categories/%E4%B8%BB%E6%B5%81%E6%A1%86%E6%9E%B6/" class="post-category">
                                    主流框架
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/MyBatis/">
                        <span class="chip bg-color">MyBatis</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                本篇&nbsp;<i class="far fa-dot-circle"></i>
            </div>
            <div class="card">
                <a href="/2021/08/29/java/hashmap/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/14.jpg" class="responsive-img" alt="HashMap相关小知识点">
                        
                        <span class="card-title">HashMap相关小知识点</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-08-29
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/java/" class="post-category">
                                    java
                                </a>
                            
                            
                        </span>
                    </div>
                </div>

                
                <div class="card-action article-tags">
                    
                    <a href="/tags/HashMap/">
                        <span class="chip bg-color">HashMap</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('120')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE' || selection.getRangeAt(0).commonAncestorContainer.nodeName === 'CODE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + '来源: 张小菜<br />'
            + '文章作者: 张小菜<br />'
            + '文章链接: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color:rgba(255,255,255,0.5);">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">

    

    

    <div class="container row center-align"
         style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right" style="color: black;font-size: 13px;">
            Copyright&nbsp;&copy;
            
                <span id="year" style="color: black">2021-2023</span>
            
            <!--<span id="year" style="color: black">2021</span>-->
            <a href="/about" target="_blank" style="color: orangered">张小菜</a>
            版权所有
            |&nbsp;Powered by&nbsp;<span style="color: orangered" target="_blank">H</span>
            |&nbsp;公安备案&nbsp;<span style="color: orangered" target="_blank">当中...</span>
            <br>
            <!--计算总字数-->
                &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                        class="white-color" style="color: orangered;">39.3k</span>
            
            
            
                
            
            <!--显示总访问量-->
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color" style="color: orangered;"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color" style="color: orangered;"></span><!--总访问人数-->
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
                <span id="sitetime"> Loading ...</span>
                <!--<script>
                    var calcSiteTime = function () {
                        var seconds = 1000;
                        var minutes = seconds * 60;
                        var hours = minutes * 60;
                        var days = hours * 24;
                        var years = days * 365;
                        var today = new Date();
                        var startYear = "2021";
                        var startMonth = "8";
                        var startDate = "1";
                        var startHour = "0";
                        var startMinute = "0";
                        var startSecond = "0";
                        var todayYear = today.getFullYear();
                        var todayMonth = today.getMonth() + 1;
                        var todayDate = today.getDate();
                        var todayHour = today.getHours();
                        var todayMinute = today.getMinutes();
                        var todaySecond = today.getSeconds();
                        var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                        var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                        var diff = t2 - t1;
                        var diffYears = Math.floor(diff / years);
                        var diffDays = Math.floor((diff / days) - diffYears * 365);

                        // 区分是否有年份.
                        var language = 'zh-CN';
                        if (startYear === String(todayYear)) {
                            document.getElementById("year").innerHTML = todayYear;
                            var daysTip = 'This site has been running for ' + diffDays + ' days';
                            if (language === 'zh-CN') {
                                daysTip = '本站已运行 ' + diffDays + ' 天';
                            } else if (language === 'zh-HK') {
                                daysTip = '本站已運行 ' + diffDays + ' 天';
                            }
                            document.getElementById("sitetime").innerHTML = daysTip;
                        } else {
                            document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                            var yearsAndDaysTip = 'This site has been running for ' + diffYears + ' years and '
                                + diffDays + ' days';
                            if (language === 'zh-CN') {
                                yearsAndDaysTip = '本站已运行 ' + diffYears + ' 年 ' + diffDays + ' 天';
                            } else if (language === 'zh-HK') {
                                yearsAndDaysTip = '本站已運行 ' + diffYears + ' 年 ' + diffDays + ' 天';
                            }
                            document.getElementById("sitetime").innerHTML = yearsAndDaysTip;
                        }
                    }

                    calcSiteTime();
                </script>-->
                <script language=javascript>
                  function siteTime() {
                    window.setTimeout("siteTime()", 1000);
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    /* Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
                    year - 作为date对象的年份，为4位年份值
                    month - 0-11之间的整数，做为date对象的月份
                    day - 1-31之间的整数，做为date对象的天数
                    hours - 0(午夜24点)-23之间的整数，做为date对象的小时数
                    minutes - 0-59之间的整数，做为date对象的分钟数
                    seconds - 0-59之间的整数，做为date对象的秒数
                    microseconds - 0-999之间的整数，做为date对象的毫秒数 */
                    var t1 = Date.UTC('2021',
                            "8",
                            "1",
                            "0",
                            "0",
                            "0"); //北京时间2018-2-13 00:00:00
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) / minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours - diffMinutes * minutes) / seconds);
                    document.getElementById("sitetime").innerHTML = "本站已运行 " +diffYears+" 年 "+diffDays + " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                  }/*因为建站时间还没有一年，就将之注释掉了。需要的可以取消*/
                  siteTime();
                </script>
            
            <br>
            
                <span id="icp"><img src="/medias/icp.png"
                                    style="vertical-align: text-bottom;"/>
                <a href="http://beian.miit.gov.cn/" target="_blank" style="color: black">湘ICP备2021014506号-1</a>
            </span>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/ZhangXiaoCaiNB" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github" style="color: #00C853;"></i>
    </a>



    <a href="mailto:3292534860@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>



    <a href="https://www.facebook.com/profile.php?id=100066270737195" class="tooltipped" target="_blank" data-tooltip="关注我的Facebook: https://www.facebook.com/profile.php?id=100066270737195" data-position="top" data-delay="50">
        <i class="fab fa-facebook-f" style="color: hotpink"></i>
    </a>



    <a href="https://twitter.com/v6gbBoT36uWweWA" class="tooltipped" target="_blank" data-tooltip="关注我的Twitter: https://twitter.com/v6gbBoT36uWweWA" data-position="top" data-delay="50">
        <i class="fab fa-twitter" style="color: #c6ff00"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=3292534860" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 3292534860" data-position="top" data-delay="50">
        <i class="fab fa-qq" style="color: #00b0ff;"></i>
    </a>







</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    
    
    <script type="text/javascript" size="150" alpha='0.6'
        zIndex="-1" src="/libs/background/ribbon.min.js" async="async"></script>
    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

    

    <!--title标签变换文字块-->
    <script type="text/javascript">
      var OriginTitile = document.title,
          st;
      document.addEventListener("visibilitychange", function () {
        document.hidden ? (document.title = "看不见我🙈~看不见我🙈~", clearTimeout(st)) : (document.title =
            "(๑•̀ㅂ•́) ✧被发现了～", st = setTimeout(function () {
          document.title = OriginTitile
        }, 3e3))
      })
    </script>

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"left","width":70,"height":140},"mobile":{"show":true},"react":{"opacity":0.7}});</script></body>

</html>
